<?php
/**
 * Created by PhpStorm.
 * User: A
 * Date: 2018/12/17
 * Time: 16:36
 */
namespace App\Api;

use PhalApi\Api;
use App\Model\Carves;

class Carve extends Api
{
    public function getRules()
    {
        return array(
            'store' => array(
                'photo' => array('name' => 'photo', 'type'=> 'file','require' => true,),
            ),
        );
    }

    public function store()
    {
        $data = [
            'photo' => "uploads/" . md5(time()). $_FILES["photo"]["name"]
        ];
        move_uploaded_file($_FILES["photo"]["tmp_name"],
            "uploads/" . md5(time()). $_FILES["photo"]["name"]);

        $carve =new  Carves();
        return $carve->store($data);

    }
}